using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using Dimok.Data;
using Dimok.Data.Database;
using Dimok.Exceptions;

namespace Dimok.Verification{

	////////////////////////////////////////////////////////////////////////////////////////////////////
	/// <summary>	Tree. </summary>
	///
	/// <remarks>	Dimon, 12/21/2010. </remarks>
	////////////////////////////////////////////////////////////////////////////////////////////////////

	public class Tree : User.UserPage{
		protected Literal ltrLoanInfo;
		protected Literal ltrTree;
		protected Literal ltrMENU_F;
		protected Literal ltrMENU_B;
		protected Literal ltrImages;
		protected Literal ltrImages_All;
		protected Literal ltrPages;
		protected Literal ltrManager;

		////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>	Gets the uox v. </summary>
		///
		/// <value>	The uox v. </value>
		////////////////////////////////////////////////////////////////////////////////////////////////////

		protected override object _uox_v{get{return _uox == null ? _uox = new UserObjectEx() : _uox;}}

		////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>	Gets the uox. </summary>
		///
		/// <value>	The uox. </value>
		////////////////////////////////////////////////////////////////////////////////////////////////////

		protected new UserObjectEx uox{get{return (UserObjectEx)_uox_v;}}

		////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>	Raises the load event. </summary>
		///
		/// <remarks>	Dimon, 12/21/2010. </remarks>
		///
		/// <exception cref="ClientException">	Thrown when client. </exception>
		///
		/// <param name="e">	Event information to send to registered event handlers. </param>
		////////////////////////////////////////////////////////////////////////////////////////////////////

		protected override void OnLoad(EventArgs e) {
			base.OnLoad(e);
			try {
				((Literal)FindControl("ltrLoanInfo")).Text = uox.LoanInfo.GetXml();
				((Literal)FindControl("ltrTree")).Text = uox.VerificationTreeXML("");
				ltrMENU_F = FindControl("ltrMENU_F") as Literal;
				ltrMENU_B = FindControl("ltrMENU_B") as Literal;
				if (ltrMENU_F != null) ltrMENU_F.Text = uox.MenusNext;
				if (ltrMENU_B != null) ltrMENU_B.Text = uox.MenusPrev;

				((Literal)FindControl("ltrImages")).Text = SQLHelperEx.XmlInnerText(uox.Images);
				((Literal)FindControl("ltrImages_All")).Text = SQLHelperEx.XmlInnerText(uox.Images_All);
				((Literal)FindControl("ltrPages")).Text = SQLHelperEx.XmlInnerText(uox.Pages);

				Controls.Add((Control)new LiteralControl("<SCRIPT>var VERIFYER = '" + uox.Verifyer + "'</SCRIPT>"));
			} catch (Exception exc) { throw new ClientException(exc); }
		}

		////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>	Event handler. Called by Page for load events. </summary>
		///
		/// <remarks>	Dimon, 12/21/2010. </remarks>
		///
		/// <param name="sender">	Source of the event. </param>
		/// <param name="e">			Event information to send to registered event handlers. </param>
		////////////////////////////////////////////////////////////////////////////////////////////////////

		private void Page_Load(object sender, System.EventArgs e){
		}
		#region Web Form Designer generated code

		////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>	Raises the initialise event. </summary>
		///
		/// <remarks>	Dimon, 12/21/2010. </remarks>
		///
		/// <param name="e">	Event information to send to registered event handlers. </param>
		////////////////////////////////////////////////////////////////////////////////////////////////////

		override protected void OnInit(EventArgs e) {
			//
			// CODEGEN: This call is required by the ASP.NET Web Form Designer.
			//
			InitializeComponent();
			base.OnInit(e);
		}

		////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>	
		/// Required method for Designer support - do not modify the contents of this method with the code
		/// editor. 
		/// </summary>
		///
		/// <remarks>	Dimon, 12/21/2010. </remarks>
		////////////////////////////////////////////////////////////////////////////////////////////////////

		private void InitializeComponent() {    
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion
	}
}
